package com.android.aconportable;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AConPortableMain extends Activity {
	/** Called when the activity is first created. */

	private Button btnConnect, btnExit;
	private EditText addr;
	public static SIPEngineClient engine;
	
	private final static int tcpPort = 9800;
	//public static UDPSocket udpsocket;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		setTitle("Recorder");

		findView();
		setListener();

	}
	


	private void findView(){
		btnConnect = (Button) this.findViewById(R.id.btnConnect);
		btnExit = (Button) this.findViewById(R.id.btnExit);
		addr = (EditText) this.findViewById(R.id.ipAddr);	
	}
	
	private void setListener(){
		btnConnect.setOnClickListener(new ClickEvent());
		btnExit.setOnClickListener(new ClickEvent());
	}
	
	class ClickEvent implements View.OnClickListener {
		public void onClick(View v){
			if (v == btnConnect){
				//engine = new SIPEngineClient(addr.getText().toString(),tcpPort);
				//engine.connect();
				//if(engine.isConnect()){
				
					Intent intent = new Intent();
					intent.setClass(AConPortableMain.this, ChatHandler.class);
					//intent.putExtra("sockets", engine);
					startActivity(intent);
				//}
			}else if (v == btnExit){
				AConPortableMain.this.finish();
			}
		}
	}
	
	/*@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data){
		super.onActivityResult(requestCode, resultCode, data);
		if(requestCode==0){
			engine = null;
		}
	}*/
	
	
	
}
